<?php

class My_Validate_Password extends Zend_Validate_Abstract {

    const NOT_MATCH = 'not-match';

    protected $_messageTemplates = array(
        self::NOT_MATCH => "Nieprawidłowe stare hasło"
    );

    public function isValid($value) {
        $userId = My_Utils::getCurrentUserId();
        $daoUser = new Application_Model_DAO_User();
        $result = $daoUser->isPasswordValid($value, $userId);
        if (!$result) {
            $this->_error(self::NOT_MATCH);
            return false;
        }

        return true;
    }

}
